<template>
	<view class="myldz">
		<u-navbar bgColor="#fff">
			<view slot="left" class="align-center">
				<image @click="$tools.back()" src="@/static/login/back3.png" style="width: 36rpx; height: 36rpx"></image>
			</view>
			<view slot="center">
				<view style="font-weight: 600; font-size: 36rpx; color: #333333">我的劳动者</view>
			</view>
		</u-navbar>
		<!-- <view class="align-center" style="padding: 32rpx">
			<view class="text1" style="margin-right: 40rpx">全部（188）</view>
			<view class="text2">入住用户（124）</view>
		</view> -->
		<view style="background: #f5f6fa; padding: 20rpx 32rpx; min-height: 100vh">
			<view class="flex" v-for="(item, index) in list" :key="index" style="padding: 20rpx; background-color: #fff; margin-bottom: 20rpx">
				<view style="margin-right: 28rpx">
					<image :src="item.userInfo.head" style="width: 196rpx; height: 240rpx" mode="aspectFill"></image>
				</view>
				<view style="flex: 1">
					<view class="flex-between1">
						<view class="align-center">
							<view style="font-weight: 600; font-size: 32rpx; color: #333333">{{ item.userInfo.name }}</view>
							<view @click.stop.native="$tools.navigite('../index/jianli', 1, item.userId)">
								<u-icon name="file-text" color="#1365F9" size="44"></u-icon>
							</view>
						</view>
						<view class="align-center">
							<view
								@click="$tools.playphone(item.userInfo.phone)"
								class="flex-center1"
								style="margin-right: 20rpx; width: 56rpx; height: 56rpx; background: #1365f9; border-radius: 8rpx"
							>
								<u-icon name="phone-fill" color="#fff" size="40"></u-icon>
							</view>
							<view
								@click="
									show = true;
									id = item.id;
								"
								class="flex-center1"
								style="width: 126rpx; height: 56rpx; background: #1365f9; border-radius: 8rpx; font-size: 24rpx; color: #ffffff"
							>
								状态变更
							</view>
						</view>
					</view>
					<u-picker :show="show" :columns="columns" @confirm="confirm" @cancel="show = false"></u-picker>
					<view
						v-if="item.postStatus == 0"
						class="flex-center1"
						style="width: 104rpx; height: 40rpx; background: #ffffff; border-radius: 8rpx; border: 1rpx solid #f9850b; font-size: 24rpx; color: #f9850b"
					>
						未上岗
					</view>
					<view
						v-if="item.postStatus == 1"
						class="flex-center1"
						style="font-size: 24rpx; color: #999999; width: 104rpx; height: 40rpx; background: #ffffff; border-radius: 8rpx; border: 1rpx solid #999999"
					>
						已上岗
					</view>
					<view style="font-weight: 300; font-size: 24rpx; color: #999999; padding: 14rpx 0">{{ item.userInfo.sex == 1 ? '男' : '女' }} | {{ item.userInfo.age }}岁</view>
					<view class="flex-wrap">
						<view style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666">
							{{ item.userInfo.workIntention }}
						</view>
						<view style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666">
							{{ item.userInfo.income }}
						</view>
						<view style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666">
							{{ item.userInfo.workTime }}
						</view>
						<view style="margin: 0 20rpx 20rpx 0; padding: 8rpx 20rpx; font-weight: 400; background: #f8f8f8; border-radius: 8rpx; font-size: 24rpx; color: #666666">
							{{ item.userInfo.workAddress }}
						</view>
					</view>
					<!-- <view style="font-weight: 400; font-size: 24rpx; color: #333333">入住日期：2024.05.31 中城知心服…</view> -->
				</view>
			</view>
			<view v-if="!list.length" style="text-align: center; padding-top: 100rpx">暂无数据~</view>
		</view>
		<view class="box">
			<image @click="$tools.navigite('./sdtj')" src="@/static/mine/add.png" style="width: 148rpx; height: 148rpx"></image>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			list: [],
			show: false,
			columns: [['未上岗', '已上岗']],
			pageNum: 1,
			pageSize: 20,
			isLastPage: false,
			id: ''
		};
	},
	onShow() {
		this.list = [];
		this.getlist();
	},
	onReachBottom() {
		if (this.isLastPage) return;
		this.pageNum++;
		this.getlist();
	},
	methods: {
		getlist() {
			const data = {
				pageNum: this.pageNum,
				pageSize: this.pageSize,
				status: -1
			};
			this.$request('front/company/myUserList', data).then((res) => {
				this.list = [...this.list, ...res.obj.list];
				console.log(res.obj.list, '列表');
				this.isLastPage = res.obj.isLastPage;
			});
		},
		confirm(e) {
			console.log('confirm', e);
			this.$request('front/company/updateLabour', {
				id: this.id,
				postStatus: e.indexs[0]
			}).then((res) => {
				if (res.code == 0) {
					this.$tools.toast('操作成功');
				}
				setTimeout(() => {
					this.list = [];
					this.getlist();
				}, 1500);
			});
			this.show = false;
		}
	}
};
</script>

<style lang="less" scoped>
.myldz {
	padding-top: calc(var(--status-bar-height) + 180rpx);
	.text1 {
		font-weight: 600;
		font-size: 28rpx;
		color: #1365f9;
	}
	.text2 {
		font-weight: 400;
		font-size: 28rpx;
		color: #999999;
	}
	.box {
		position: fixed;
		bottom: 100rpx;
		right: 32rpx;
	}
}
</style>
